package com.brillilab.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;

@Getter
@AllArgsConstructor
public enum TimeEnum {

        ONE(1, LocalTime.of(6,0),LocalTime.of(7,0)),
        TWO(2, LocalTime.of(7,0),LocalTime.of(8,0)),
        THREE(3, LocalTime.of(8,0),LocalTime.of(9,0)),
        FOUR(4, LocalTime.of(9,0),LocalTime.of(10,0)),
        FIVE(5, LocalTime.of(10,0),LocalTime.of(11,0)),
        SIX(6, LocalTime.of(11,0),LocalTime.of(12,0)),
        SEVEN(7, LocalTime.of(12,0),LocalTime.of(13,0)),
        EIGHT(8, LocalTime.of(13,0),LocalTime.of(14,0)),
         NINE(9, LocalTime.of(14,0),LocalTime.of(15,0)),
        TEN(10, LocalTime.of(15,0),LocalTime.of(16,0)),
        ELEVEN(11, LocalTime.of(16,0),LocalTime.of(17,0)),
        TWELVE(12, LocalTime.of(17,0),LocalTime.of(18,0)),
        THIRTEEN(13, LocalTime.of(18,0),LocalTime.of(19,0)),
        FOURTEEN(14, LocalTime.of(19,0),LocalTime.of(20,0)),
        FIFTEEN(15, LocalTime.of(20,0),LocalTime.of(21,0)),
        SIXTEEN(16, LocalTime.of(21,0),LocalTime.of(22,0)),
        SEVENTEEN(17, LocalTime.of(22,0),LocalTime.of(23,0)),
        EIGHTEEN(18, LocalTime.of(23,0),LocalTime.of(0,0)),
        NINETEEN(19, LocalTime.of(0,0),LocalTime.of(1,0)),
        TWENTY(20, LocalTime.of(1,0),LocalTime.of(2,0)),
        TWENTY_ONE(21, LocalTime.of(2,0),LocalTime.of(3,0)),
        TWENTY_TWO(22, LocalTime.of(3,0),LocalTime.of(4,0)),
        TWENTY_THREE(23, LocalTime.of(4,0),LocalTime.of(5,0)),
        TWENTY_FOUR(24, LocalTime.of(5,0),LocalTime.of(6,0)),
        ;


        private Integer value;
        private LocalTime start;
        private LocalTime end;

        public static   Integer getValueByTime(LocalTime time){
                for (TimeEnum t : TimeEnum.values()){
                        if (t.getStart().compareTo(time)<=0 && t.getEnd().compareTo(time) >0){
                                return t.value;
                        }
                }
                return null;
        }

        public static   LocalTime getTimeByValue(Integer value){
                for (TimeEnum t : TimeEnum.values()){
                        if (t.value.equals(value)){
                                return t.getStart();
                        }
                }
                return null;
        }

        public static List<Integer> getValueList(){
            List<Integer> values = new ArrayList<>();
            for (TimeEnum t: TimeEnum.values()){
                values.add(t.value);
            }
            return values;
        }
}
